<?php
    $db = Zend_Db_Table::getDefaultAdapter();
    $profiler = $db->getProfiler();
    $this->jQuery()->addOnLoad("
$('#showProfiler').on('click', function() {
    $('#profiler').dialog({
        width: 800,
        modal: true,
        resizable: false,
        buttons: {
            Ok: function() {
                $(this).dialog('close');
            }
        }
    });

});

    ");
?>
<?php if ($profiler->getEnabled() && $profiler->getTotalNumQueries()): ?>
<a href="javascript:void(0)" id="showProfiler">
    Profiler (
        Queries: <?php echo $profiler->getTotalNumQueries(); ?>,
        Time: <?php echo $profiler->getTotalElapsedSecs(); ?>
    )
</a>
<div id="profiler" class="hidden">
    <table class="spreadsheet">
        <thead>
            <tr>
                <th>#</th>
                <th>Query</th>
                <th>Time</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($profiler->getQueryProfiles() as $num => $query): ?>

            <tr>
                <td><?php echo $num + 1; ?></td>
                <td><?php echo $query->getQuery(); ?></td>
                <td><?php echo $query->getElapsedSecs(); ?></td>
            </tr>
            <?php endforeach; ?>

        </tbody>
    </table>
</div>
<?php endif; ?>
